﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace PaymentApp
{
    /// <summary>
    /// 支付方式的动态操作，易于维护
    /// </summary>
    class Program
    {
        static void Main(string[] args)
        {
            Order order = new Order();

            //可以由用户选择，也可以由系统选择
            // 支付方式，通过读取配置文件来获取 
            var path = @"payconfig.txt";
            var condition = File.ReadAllText(path);
            switch (condition)
            {
                case "WxPayment":
                    order.SetPayment(new WxPayment());
                    break;
                case "AliPayment":
                    order.SetPayment(new AliPayment());
                    break;
                default:
                    order.SetPayment(new WxPayment());
                    break;
            }
            order.Pay(100M);

            Console.ReadKey();
        }
    }
}
